package com.yuandian.exception;

import com.yuandian.bpm.common.core.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 说明：bpm服务全局异常处理
 * @Author zfsn
 * @Date 2023/3/14 15:32
 */
@Slf4j
@RestControllerAdvice
@Component
@ConditionalOnExpression("!'${security.oauth2.client.clientId}'.isEmpty()")
public class GlobalBpmExceptionHandler {

	/**
	 * 通用接口sql模板异常
	 * @param e sql模板异常
	 * @return 通用返回对象
	 */
	@ExceptionHandler(SqlTemplateException.class)
	@ResponseStatus(HttpStatus.OK)
	public R handleSqlTemplateException(SqlTemplateException e) {
		log.error(e.getMessage());
		return R.failed("123");
	}
}
